package com.ruoyi.web.controller.example;


import com.ruoyi.common.annotation.Anonymous;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.example.domain.User;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

@Anonymous
@Api(tags="Swagger参数")
@RestController
@RequestMapping("/bind")
public class BindController {
    @ApiOperation("url参数")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "name", value = "用户名称", required = false,
                    dataType = "String", dataTypeClass = String.class),
            @ApiImplicitParam(name = "sex", value = "用户性别", required = true,
                    dataType = "String", dataTypeClass = String.class)
    })
    @GetMapping("/name")
    public String getUserName(@RequestParam(value="name",required = false) String userName,@RequestParam("sex") String sex){
        return userName + " " + sex;
    }
    @ApiOperation("路径参数")
    @ApiImplicitParam(name = "id", value = "用户id", required = true,
            paramType ="path" ,
            dataType = "String", dataTypeClass = String.class)
    @GetMapping("/ids/{id}")
    public String getUserId(@PathVariable("id") String userId) {
        return userId;
    }
    @ApiOperation("新增用户")
    @PostMapping("/user")
    public AjaxResult addUser(@RequestBody User user){
        return AjaxResult.success(user);
    }

}
